/**
 * Created by shitao on 15/10/17.
 */

(function () {
    // 创建service对象
    angular.module('my-tabs.services')
        .factory('adService', adService);
    // 申明依赖
    adService.$inject = ['appApi'];

    function adService(appApi) {

        var ads = [];

        return {

            load: function () {
                return appApi.getAds().success(function (items) {
                    ads.length = 0;
                    _.each(items, function(item){
                        ads.push(item);
                    })
                });
            },

            all: function(){
                return ads;
            }

        };
    };
})();
